<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			div {
				width: 200px;
				height: 200px;
				background: red;
			}
		</style>
	</head>
	<body>
		<input type="button" value="body按钮" id="ipt" />
		<input type="button" value="div按钮" id="odiv" />
		<span id="ood"></span>
		<script>
			var i = 0;
			ipt.onclick = function() {
				if (i < 1) {
					var oipt = document.createElement('input');
					oipt.value = '生成按钮';
					oipt.type = 'button';
					oipt.id = 'oipt'
					console.log(oipt);
					document.body.appendChild(oipt);
				} else {
					alert('只能生成一个');
				}
				i++;
			}
			odiv.onclick = function() {
				if (i < 10) {
					var ddv = document.createElement('div');
					console.log(ddv);
					ddv.innerHTML = i;
					ood.appendChild(ddv);
					i++;
				}else{
					alert('生成太多了');
				}

			}
		</script>
	</body>
</html>